package com.xiaoyung.easyisapisdk.common.base;

import java.util.List;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonView;

//import io.swagger.annotations.ApiModelProperty;

public class RowsData<T>{
	
	@JsonView(GeneralViews.class)
	//@ApiModelProperty(value = "总记录数")
    private Long total;
	
	@JsonView(GeneralViews.class)
	//@ApiModelProperty(value = "列表数据")
    private List<T> list;
	
	@JsonView(GeneralViews.class)
	//@ApiModelProperty(value = "pageNo")
	private Integer pageNo;

	@JsonView(GeneralViews.class)
	//@ApiModelProperty(value = "pageSize")
	private Integer pageSize;

	public RowsData() {
		
	}
	
	public RowsData(List<T> list) {
		this.list=list;
		if(list!=null) {
			if(list instanceof PageList) {
				PageList<T> page = ((PageList<T>)list);
				this.pageNo = page.getPageNo();
				this.pageSize = page.getPageSize();
				this.total = page.getTotal() == null ? 0l : Long.valueOf(page.getTotal());
			}else {
				this.total = Long.valueOf(list.size());
			}
		}
		if(this.total==null) {
			this.total = 0l;
		}
	}
	
	public RowsData(List<T> rows,Long total) {
		this.list=rows;
		this.total=total;
	}

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public Integer getPageNo() {
		return pageNo;
	}

	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public String toString() {
		return this==null?null:JSON.toJSONString(this);
	}
}